﻿using System.Windows;
#if NETFX_CORE
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
#else
using System.Windows.Data;
#endif
using MugenMvvmToolkit.Converters;

namespace MugenMvvmToolkit.Bindings
{
    /// <summary>
    ///     This converts a NullValue to a Visibility.Collapsed, NotNullValue to Visibility.Visible.
    /// </summary>
    public sealed class NullToCollapsedBinding : Binding
    {
        #region Fields

        private static readonly NullToVisibilityConverter VisibilityConverter = new NullToVisibilityConverter
                                                                                    {
                                                                                        NullValue = Visibility.Collapsed,
                                                                                        NotNullValue =
                                                                                            Visibility.Visible
                                                                                    };

        #endregion

        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="TrueToCollapsedBinding" /> class.
        /// </summary>
        public NullToCollapsedBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        ///     Initializes a new instance of the <see cref="TrueToCollapsedBinding" /> class with an initial path.
        /// </summary>
        /// <param name="path">
        ///     The initial <see cref="P:System.Windows.Data.Binding.Path" /> for the binding.
        /// </param>
        public NullToCollapsedBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif

        #endregion
    }

    /// <summary>
    ///     This converts a NullValue to a Visibility.Visible, NotNullValue to Visibility.Collapsed.
    /// </summary>
    public sealed class NotNullToCollapsedBinding : Binding
    {
        #region Fields

        private static readonly NullToVisibilityConverter VisibilityConverter = new NullToVisibilityConverter
        {
            NullValue = Visibility.Visible,
            NotNullValue = Visibility.Collapsed
        };

        #endregion

        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="TrueToCollapsedBinding" /> class.
        /// </summary>
        public NotNullToCollapsedBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        ///     Initializes a new instance of the <see cref="TrueToCollapsedBinding" /> class with an initial path.
        /// </summary>
        /// <param name="path">
        ///     The initial <see cref="P:System.Windows.Data.Binding.Path" /> for the binding.
        /// </param>
        public NotNullToCollapsedBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif

        #endregion
    }

#if WPF
    /// <summary>
    ///     This converts a NullValue to a Visibility. NotNullValue to Visibility.Visible, NullValue to Visibility.Hidden.
    /// </summary>
    public sealed class NullToHiddenBinding : Binding
    {
        #region Fields

        private static readonly NullToVisibilityConverter VisibilityConverter = new NullToVisibilityConverter
        {
            NullValue =
                Visibility.Hidden,
            NotNullValue = Visibility.Visible
        };

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NullToHiddenBinding"/> class.
        /// </summary>
        public NullToHiddenBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        /// Initializes a new instance of the <see cref="NullToHiddenBinding"/> class with an initial path.
        /// </summary>
        /// <param name="path">The initial <see cref="P:System.Windows.Data.Binding.Path"/> for the binding.
        ///                 </param>
        public NullToHiddenBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif
        #endregion
    }

    /// <summary>
    ///     This converts a NullValue to a Visibility. NotNullValue to Visibility.Hidden, NullValue to Visibility.Visible.
    /// </summary>
    public sealed class NotNullToHiddenBinding : Binding
    {
        #region Fields

        private static readonly NullToVisibilityConverter VisibilityConverter = new NullToVisibilityConverter
        {
            NullValue = Visibility.Visible,
            NotNullValue = Visibility.Hidden
        };

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NotNullToHiddenBinding"/> class.
        /// </summary>
        public NotNullToHiddenBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        /// Initializes a new instance of the <see cref="NotNullToHiddenBinding"/> class with an initial path.
        /// </summary>
        /// <param name="path">The initial <see cref="P:System.Windows.Data.Binding.Path"/> for the binding.
        ///                 </param>
        public NotNullToHiddenBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif
        #endregion
    }
#endif
}